package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.HotelOrders;
import com.ruoyi.system.service.IHotelOrdersService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 酒店订单模块Controller
 * 
 * @author ruoyi
 * @date 2024-12-21
 */
@RestController
@RequestMapping("/system/hotelOrders")
public class HotelOrdersController extends BaseController
{
    @Autowired
    private IHotelOrdersService hotelOrdersService;

    /**
     * 查询酒店订单模块列表
     */
    @PreAuthorize("@ss.hasPermi('system:hotelOrders:list')")
    @GetMapping("/list")
    public TableDataInfo list(HotelOrders hotelOrders)
    {
        startPage();
        List<HotelOrders> list = hotelOrdersService.selectHotelOrdersList(hotelOrders);
        return getDataTable(list);
    }

    /**
     * 导出酒店订单模块列表
     */
    @PreAuthorize("@ss.hasPermi('system:hotelOrders:export')")
    @Log(title = "酒店订单模块", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HotelOrders hotelOrders)
    {
        List<HotelOrders> list = hotelOrdersService.selectHotelOrdersList(hotelOrders);
        ExcelUtil<HotelOrders> util = new ExcelUtil<HotelOrders>(HotelOrders.class);
        util.exportExcel(response, list, "酒店订单模块数据");
    }

    /**
     * 获取酒店订单模块详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:hotelOrders:query')")
    @GetMapping(value = "/{hotelOrderid}")
    public AjaxResult getInfo(@PathVariable("hotelOrderid") Long hotelOrderid)
    {
        return success(hotelOrdersService.selectHotelOrdersByHotelOrderid(hotelOrderid));
    }

    /**
     * 新增酒店订单模块
     */
    @PreAuthorize("@ss.hasPermi('system:hotelOrders:add')")
    @Log(title = "酒店订单模块", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HotelOrders hotelOrders)
    {
        return toAjax(hotelOrdersService.insertHotelOrders(hotelOrders));
    }

    /**
     * 修改酒店订单模块
     */
    @PreAuthorize("@ss.hasPermi('system:hotelOrders:edit')")
    @Log(title = "酒店订单模块", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HotelOrders hotelOrders)
    {
        return toAjax(hotelOrdersService.updateHotelOrders(hotelOrders));
    }

    /**
     * 删除酒店订单模块
     */
    @PreAuthorize("@ss.hasPermi('system:hotelOrders:remove')")
    @Log(title = "酒店订单模块", businessType = BusinessType.DELETE)
	@DeleteMapping("/{hotelOrderids}")
    public AjaxResult remove(@PathVariable Long[] hotelOrderids)
    {
        return toAjax(hotelOrdersService.deleteHotelOrdersByHotelOrderids(hotelOrderids));
    }
}
